//
//  TBROrderListC.m
//  TBRentClient
//
//  Created by tonbright on 2018/4/26.
//  Copyright © 2018年 tonbright. All rights reserved.
//

#import "TBROrderListC.h"

#import "TBROrderListCell.h"
#import "TBROrderListHeadView.h"
#import "TBRLoginController.h"

#import "BaseNavigationController.h"
@interface TBROrderListC ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView      *tableView;

@end

@implementation TBROrderListC

- (void)viewDidLoad {
    [super viewDidLoad];
    //设置界面-----
    [self setupUI];
}

- (void)setupUI {
    //设置导航条
    [self setupNavItem];
    
    //添加tableView
    [self setupTableView];
}

- (void)setupNavItem {
    self.titleText = @"订单一览";
}

- (void)setupTableView {
    self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
    [self.view addSubview:self.tableView];
    self.tableView.backgroundColor = [UIColor colorWithHex:0xe6e6e6];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.offset(0);
        make.leading.offset(10);
        make.trailing.offset(-10);
    }];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.tableFooterView = [UIView new];
    [self.tableView registerNib:[UINib nibWithNibName:@"TBROrderListCell" bundle:nil] forCellReuseIdentifier:@"TBROrderListCellId"];
    [self.tableView registerNib:[UINib nibWithNibName:@"TBROrderPlaneListCell" bundle:nil] forCellReuseIdentifier:@"TBROrderPlaneListCellId"];
    self.tableView.rowHeight = UITableViewAutomaticDimension;
    self.tableView.estimatedRowHeight = 100;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.showsVerticalScrollIndicator = NO;

}

#pragma mark - 返回组
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 2;
}

#pragma mark - 返回行
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 2;
}

#pragma mark - 返回每行内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    //自定义cell
    TBROrderListCell *cell = [tableView dequeueReusableCellWithIdentifier:[self getIdentifier:indexPath] forIndexPath:indexPath];
    //    cell.goodsModel = self.allGoodsArray[indexPath.row];
    //设置数据
    //返回
    [self setupCell:cell indexPath:indexPath];
    return cell;
}

- (NSString *)getIdentifier:(NSIndexPath *)indexPath {
    NSString *iden = @"TBROrderPlaneListCellId";
    if (indexPath.row == 0) {
        iden = @"TBROrderPlaneListCellId";
    }else {
        iden = @"TBROrderListCellId";
    }
    return iden;
}

- (void)setupCell:(TBROrderListCell *)cell indexPath:(NSIndexPath *)indexPath {
    
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    if(section == 0) {
        TBROrderListHeadView *headView = [TBROrderListHeadView orderListHeadView];
        return headView;
    }
    TBROrderListHeadView *headView = [TBROrderListHeadView orderListHeadView];
    return headView;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    if (section == 1) {
        return 30;
    }
    return 44;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

@end
